package plugins.view360
{
	import flash.display.Sprite;
	import flash.events.Event;
	
	import org.papervision3d.core.proto.SceneObject3D;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.utils.MaterialsList;
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.render.BasicRenderEngine;
	import org.papervision3d.view.Viewport3D;
	
	import pv3d.cameras.RotateableTargetCamera;
	
	public class View360 extends Sprite
	{
		private var renderer:BasicRenderEngine;           //3D场景的渲染器
		private var container:SceneObject3D;              //3D场景模块的容器
		private var camera:RotateableTargetCamera;        //3D场景的镜头
		private var viewport:Viewport3D;                  //3D场景的视窗
		private var model:DAE;
		public function View360()
		{
			renderer = new BasicRenderEngine();
			container = new SceneObject3D();
			viewport = new Viewport3D(900, 480, false, false);
			viewport.interactive=true;
			this.addChild(viewport);
			camera = new RotateableTargetCamera();
			model=new DAE(false);
			container.addChild(model);
			var list:MaterialsList=new MaterialsList();
			var material:BitmapFileMaterial=new BitmapFileMaterial("resource/image/3d/view360/image19.jpg");
			material.smooth=true;
			list.addMaterial(material,"all");
			model.load("resource/image/3d/view360/shouji.DAE",list);
			this.addEventListener(Event.ENTER_FRAME,on_enter);
		}
		private function on_enter(e:Event):void
		{
			renderer.renderScene(container,camera,viewport);
		}
	}
}